Check for psitrex comment sign in header names. Allocate always a track header in...
authoroliskoli <oliskoli>
Tue, 28 Nov 2006 12:48:00 +0000 (12:48 +0000)
committeroliskoli <oliskoli>
Tue, 28 Nov 2006 12:48:00 +0000 (12:48 +0000)
psitrex.c

index 62443341717a498ad811a187714874718fc41c92..d0d6c7187083deeb6dc37205c378121b17fc72ad 100755 (executable)
--- a/psitrex.c
+++ b/psitrex.c
@@ -468,6 +468,8 @@ psit_routehdr_w(FILE *psit_file, const route_head *rte)
        allWptNameLengths = 0;
 
        if (rte->waypoint_list.next) {          /* this test doesn't do what I want i.e test if this is a valid route - treat as a placeholder for now */
+               char *c;
+               
                QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) {
                        testwpt = (waypoint *)elem;
                        if (rte_datapoints == 0) {
@@ -488,8 +490,10 @@ psit_routehdr_w(FILE *psit_file, const route_head *rte)
                else
                        rname = xstrdup(rte->rte_name);
 
-               fprintf(psit_file, "Route:  %s\n",
-                                                       rname);
+               /* check for psitrex comment sign; replace with '$' */
+               while ((c = strchr(rname, '#'))) *c = '$';
+
+               fprintf(psit_file, "Route:  %s\n", rname);
                xfree(rname);
        }
 }
@@ -532,6 +536,8 @@ psit_track_r(FILE *psit_file, route_head **trk)
        trk_num = 0;
 
        trk_count = 0;
+       
+       track_head = NULL;
 
        psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), wscomma);
 
@@ -575,7 +581,7 @@ psit_track_r(FILE *psit_file, route_head **trk)
 
                        psit_getToken(psit_file,psit_current_token,sizeof(psit_current_token), whitespace);
 
-                       if (strcmp(psit_current_token, "1") == 0) {
+                       if ((strcmp(psit_current_token, "1") == 0) || (track_head == NULL)) {
                                track_head = route_head_alloc();
                                /* Add a number to the track name.  With Garmins, the "first" tracklog is usually ACTIVE LOG
                                   the second is ACTIVE LOG001 and so on */
@@ -621,6 +627,8 @@ psit_trackhdr_w(FILE *psit_file, const route_head *trk)
                /* total nodes (waypoints) this track */
                trk_datapoints = 0;
                if (trk->waypoint_list.next) {  /* this test doesn't do what I want i.e test if this is a valid track - treat as a placeholder for now */
+                       char *c;
+                       
                        QUEUE_FOR_EACH(&trk->waypoint_list, elem, tmp) {
                                if (trk_datapoints == 0) {
                                        testwpt = (waypoint *)elem;
@@ -641,8 +649,10 @@ psit_trackhdr_w(FILE *psit_file, const route_head *trk)
                        else
                                tname = xstrdup(trk->rte_name);
 
-                       fprintf (psit_file, "Track:  %s\n",
-                                                               tname);
+                       /* check for psitrex comment sign; replace with '$' */
+                       while ((c = strchr(tname, '#'))) *c = '$';
+                       
+                       fprintf (psit_file, "Track:  %s\n", tname);
 
                        xfree(tname);
                }